// 抽象类Employee
abstract class Employee {
    String name;
    double salary;

    public Employee(String name, double salary) {
        this.name = name;
        this.salary = salary;
    }

    // 抽象方法，用于计算工资
    public abstract double calculateSalary();
}

// 月薪员工类，继承自Employee
class SalariedEmployee extends Employee {
    public SalariedEmployee(String name, double salary) {
        super(name, salary);
    }

    @Override
    public double calculateSalary() {
        return salary;
    }
}

// 时薪员工类，继承自Employee
class HourlyEmployee extends Employee {
    private double hoursWorked;

    public HourlyEmployee(String name, double hourlyRate, double hoursWorked) {
        super(name, hourlyRate);
        this.hoursWorked = hoursWorked;
    }

    @Override
    public double calculateSalary() {
        return salary * hoursWorked;
    }
}

public class Main {
    public static void main(String[] args) {
        Employee[] employees = new Employee[10];  // 假设创建10个员工示例

        for (int i = 0; i < employees.length; i++) {
            int randomChoice = (int) (Math.random() * 2);
            if (randomChoice == 0) {
                // 生成月薪员工示例数据
                String name = "SalariedEmp" + i;
                double salary = 5000 + Math.random() * 5000;  // 工资范围5000到10000
                employees[i] = new SalariedEmployee(name, salary);
            } else {
                // 生成时薪员工示例数据
                String name = "HourlyEmp" + i;
                double hourlyRate = 20 + Math.random() * 30;  // 时薪范围20到50
                double hoursWorked = 100 + Math.random() * 100;  // 工时范围100到200
                employees[i] = new HourlyEmployee(name, hourlyRate, hoursWorked);
            }
        }

        for (Employee employee : employees) {
            System.out.println(employee.name + " 的工资是: " + employee.calculateSalary());
        }
    }
}